using RecruitmentAgency.Controllers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.Web;
using System.Web.Mvc;
using System.Web;
using RecruitmentAgency.Models.DataTypes;

namespace RecruitmentAgency.Tests
{
    
    
    /// <summary>
    ///This is a test class for CvControllerTest and is intended
    ///to contain all CvControllerTest Unit Tests
    ///</summary>
    [TestClass()]
    public class CvControllerTest
    {
        private TestContext testContextInstance;
        private CvController target;

        /// <summary>
        ///Initialises test members
        ///</summary>
        [TestInitialize]
        public void Initialize()
        {
            // create mock DataProvider
            //mockDataProvider = new Mock<IDataProvider>();
            target = new CvController();
        }

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        /// <summary>
        ///A test for GET ViewCvs
        ///</summary>
        [TestMethod()]
        public void ViewCvsGetTest()
        {
            int page = 1;
            ViewResult actual = (ViewResult)target.ViewCvs(page);
            // check that there are 6 items in the ViewData
            Assert.AreEqual(6, actual.ViewData.Count);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
        }

        /// <summary>
        ///A test for POST ViewCvs
        ///</summary>
        [TestMethod()]
        public void ViewCvsPostTest()
        {
            ViewResult actual = (ViewResult)target.ViewCvs(1, new CvSearchData
            {
                PageSize = 10,
                PageNumber = 1,
                SkillName = string.Empty,
                QualificationType = string.Empty,
                QualificationSubject = string.Empty,
                JobSectorPreference = string.Empty,
                MinimumNumberOfGcse = string.Empty,
                MinimumNumberOfALevel = string.Empty,
            });
            // check that there are 6 items in the ViewData
            Assert.AreEqual(6, actual.ViewData.Count);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
        }

        /// <summary>
        ///A test for ViewCv
        ///</summary>
        [TestMethod()]
        public void ViewCvTest()  // the HttpRequest object is null so test fails
        {
            int id = 1;
            ViewResult actual = (ViewResult)target.ViewCv(id);
            // check that there is 1 item in the ViewData
            Assert.AreEqual(1, actual.ViewData.Count);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
            // check that the current user ID is still the same
            Assert.AreEqual(id, ((CvData)actual.ViewData.Model).CurrentUserId);
        }

        /// <summary>
        ///A test for GET Edit
        ///</summary>
        [TestMethod()]
        public void EditGetTest()
        {
            int id = 1;
            ViewResult actual = (ViewResult)target.Edit(id);
            // check that there are 19 items in the ViewData
            Assert.AreEqual(19, actual.ViewData.Count);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
        }

        /// <summary>
        ///A test for POST Edit
        ///</summary>
        [TestMethod()]
        public void EditPostTest()
        {
            int id = 1;
            ViewResult actual = (ViewResult)target.Edit(id, new PersonalDetail(), null, new PersonQualification(), new PersonEmployment(), new PersonSkill (), new PersonReferee());
            // check that there are 19 items in the ViewData
            Assert.AreEqual(19, actual.ViewData.Count);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
        }

        /// <summary>
        ///A test for GET DeleteRecord
        ///</summary>
        [TestMethod()]
        public void DeleteRecordGetTest()
        {
            int id = 1;
            ViewResult actual = (ViewResult)target.DeleteRecord(id);
            // check that there are 5 items in the ViewData
            Assert.AreEqual(5, actual.ViewData.Count);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
        }

        /// <summary>
        ///A test for POST DeleteRecord
        ///</summary>
        [TestMethod()]
        public void DeleteRecordPostTest()
        {
            int id = 1;
            RedirectToRouteResult actual = (RedirectToRouteResult)target.DeleteRecord(id, new PersonQualification(), new PersonEmployment(), new PersonSkill(), new PersonReferee());
            // check that the request gets redirected back to the DeleteRecord page
            Assert.AreEqual("DeleteRecord", actual.RouteValues["action"]);
            // check that the current user ID is still the same
            Assert.AreEqual(id, actual.RouteValues["id"]);
        }

        /// <summary>
        ///A test for GET Delete
        ///</summary>
        [TestMethod()]
        public void DeleteGetTest()
        {
            int id = 1;
            ViewResult actual = (ViewResult)target.DeleteRecord(id);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
        }

        /// <summary>
        ///A test for POST Delete
        ///</summary>
        [TestMethod()]
        public void DeletePostTest()
        {
            int id = 1000000;
            RedirectToRouteResult actual = (RedirectToRouteResult)target.Delete(id, new PersonalDetail());
            // check that the request gets redirected back to the ViewCvs page
            Assert.AreEqual("ViewCvs", actual.RouteValues["action"]);
        }

        /// <summary>
        ///A test for GET Create
        ///</summary>
        [TestMethod()]
        public void CreateGetTest()
        {
            //target.CurrentPersonId = 1000;
            ViewResult actual = (ViewResult)target.Create();
            // check that there are 19 items in the ViewData
            Assert.AreEqual(19, actual.ViewData.Count);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
        }

        /// <summary>
        ///A test for POST Create
        ///</summary>
        [TestMethod()]
        public void CreatePostTest()
        {
            int id = 1;
            ViewResult actual = (ViewResult)target.Edit(id, new PersonalDetail(), null, new PersonQualification(), new PersonEmployment(), new PersonSkill(), new PersonReferee());
            // check that there are 19 items in the ViewData
            Assert.AreEqual(19, actual.ViewData.Count);
            // check that there is a data model in the ViewData
            Assert.IsNotNull(actual.ViewData.Model);
        }
    }
}